package com.josephxu.tank.abstractfactory;

import com.josephxu.tank.Audio;
import com.josephxu.tank.ResourceMgr;
import com.josephxu.tank.TankFrame;

import java.awt.*;

/**
 * @Author: Joseph Xu
 * @Date: 2022/1/30 15:33
 */
public class RectExplode extends BaseExplode {
    public static int WIDTH = ResourceMgr.explode[0].getWidth(),
            HEIGHT = ResourceMgr.explode[0].getHeight();


    TankFrame tf = null;

    private int x,y;
    //画到第几步
    private int step = 0;

    public RectExplode(int x, int y, TankFrame tf) {
        super();
        this.x = x;
        this.y = y;
        this.tf = tf;

        new Thread(()->new Audio("audio/explode.wav").play()).start();

    }

    @Override
    public void paint(Graphics g) {
        Color c = g.getColor();
        g.setColor(Color.RED);
        g.fillRect(x,y,10*step,10*step);
        step++;
        if (step >= ResourceMgr.explode.length){
            tf.explodes.remove(this);
        }
    }
}
